package com.hfy.music.mapper;

import com.hfy.model.vo.MusicVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @ author 韩
 * time: 2024/6/4 17:55
 */
@Mapper
public interface MusicUserMapper {

    @Select("SELECT COUNT(*) FROM `music_like` WHERE account = #{account} AND biz = 0")
    Integer getMusicNum(Long account);

    @Select("SELECT music.id id, music.name `name`, `music_url` music, album.cover cover, musician.musician_name `musician` , album.create_time `createTime`, " +
            " album.name `album`, music.duration `duration` " +
            "FROM music " +
            "LEFT JOIN music_like ON music.id = music_like.biz_id AND music_like.biz = 0 AND music_like.account = #{account} " +
            "LEFT JOIN album ON music.album_id = album.id " +
            "LEFT JOIN musician ON music.musician_id = musician.id" )
    List<MusicVo> getMusic(@Param("account") Long account);




}
